package com.cch.examSystem.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.cch.examSystem.entity.FunGameQuestion;
import com.cch.examSystem.entity.FunGameStudent;
import com.cch.examSystem.entity.Manager;
import com.cch.examSystem.entity.StudentList;

public class FunGameQuestionListServlet extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		doPost(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		Date now = new Date();
		SimpleDateFormat datetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		SimpleDateFormat date = new SimpleDateFormat("yyyy-MM-dd");
		SimpleDateFormat time = new SimpleDateFormat("HH:mm:ss");
		response.setContentType("text/html");
		

		List<FunGameQuestion> userList = new ArrayList();
		Map map=new HashMap();
		map.put("A", "若ｆ（ X ）在 X＝Xo连续，  则ｆ（ X ）在X＝Xo可导");
		map.put("B", "若ｆ（ X ）在 X＝Xo不可导，则ｆ（ X ）在X＝Xo不连续");
		map.put("C", "若ｆ（ X ）在 X＝Xo不可微，则ｆ（ X ）在X＝Xo极限不存");
		map.put("D", "若ｆ（ X ）在 X＝Xo不连续，则ｆ（ X ）在X＝Xo不可导");
		FunGameQuestion user;
		
		for (int i = 0; i < 50; i++) {
			user = new FunGameQuestion(i,(int)(Math.random()*10),"题目"+i,
				JSON.toJSONString(map).toString(),"A",5,"1"
			);
			JSONObject json=(JSONObject)JSON.parse(user.getOptions());
			user.setA(json.get("A").toString());
			user.setB(json.get("B").toString());
			user.setC(json.get("C").toString());
			user.setD(json.get("D").toString());
			userList.add(user);
		}
		
		HttpSession session = request.getSession();
		session.setAttribute("fungameQuestionList", userList);

		response.sendRedirect("./manager/FunGameQuestionList.jsp");

	}

}
